import 'repo_model.dart';

// 代表搜索 API 的返回结果
class SearchResult {
  final int totalCount;
  final List<Repo> items;

  SearchResult({required this.totalCount, required this.items});

  factory SearchResult.fromJson(Map<String, dynamic> json) {
    var repoList = <Repo>[];
    if (json['items'] != null) {
      repoList = (json['items'] as List).map((item) => Repo.fromJson(item)).toList();
    }
    return SearchResult(
      totalCount: json['total_count'] ?? 0,
      items: repoList,
    );
  }
}
